package com.dz.fz.control;

import com.dz.fz.bean.userBean;
import com.dz.fz.modal.LonginedModal;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet( "/LoginedNameServlet")
public class LoginedNameServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        userBean userB = new userBean();
        userB.setUserName(request.getParameter("adminName"));
        userB.setUserPsw(request.getParameter("adminPsw"));


        LonginedModal lm = new LonginedModal();
        boolean isOk = lm.doSelect(userB);

        if(isOk){
            request.getSession().setAttribute("LoginName",userB.getUserName());
            request.getRequestDispatcher("WEB-INF/show.jsp").forward(request,response);
        }else{
            response.sendRedirect("index.jsp");
        }
    }
}

